﻿using System;
using System.Linq;

namespace GameStudio.IDE.Store
{
    public class Store : IStore
    {
        private readonly ExecuteProvider _executeProvider;

        /// <summary>
        /// Initializes a new instance of the <see cref="Store"/> class.
        /// </summary>
        /// <param name="executeProvider">The execute provider.</param>
        public Store(ExecuteProvider executeProvider)
        {
            _executeProvider = executeProvider;
        }
        /// <summary>
        /// Gets the by key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        public ItemBase GetByKey(string key)
        {
            return _executeProvider.GetItems(key).Single();
        }

        public void Save(ItemBase value)
        {
            //throw new NotImplementedException();
        }

        public void Update(string key, object value)
        {
            _executeProvider.UpdateItem(key, value);
        }
        public void Delete(string key)
        {
            _executeProvider.DeleteItem(key);
        }
    }
}
